<!-- 年度游客组件 -->
<template>
  <div class="tearTouist">
    <div class="container">
      <!-- 标题 -->
      <div class="tit">年度游客量对比</div>
      <!-- 柱状图 -->
      <div class="echarts" ref="charts"></div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { onMounted, reactive, ref } from 'vue'
/* 引入 echarts */
import * as echarts from 'echarts'
/* echart DOM实例 */
const charts = ref<any>()
/* 需要渲染的echarts数据 */
const yearTouistCharts = reactive<any>({
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      // Use axis to trigger tooltip
      type: 'shadow', // 'shadow' as default; can also be 'line' or 'shadow'
    },
  },
  legend: {
    top: '30px',
    textStyle: {
      color: '#fff',
    },
  },
  grid: {
    left: 0,
    right: 0,
    bottom: 0,
    containLabel: true,
  },
  xAxis: {
    type: 'value',
  },
  yAxis: {
    type: 'category',
    data: ['三月', '六月', '九月', '十二月'],
  },
  series: [
    {
      name: '灵谷峰',
      type: 'bar',
      stack: 'total',
      label: {
        show: true,
        textStyle: {
          color: '#fff',
        },
      },
      emphasis: {
        focus: 'series',
      },
      data: [800, 999, 1012, 888, 1240, 785, 5555],
      textStyle: {
        color: '#fff',
      },
    },
    {
      name: '仙盖山',
      type: 'bar',
      stack: 'total',
      label: {
        show: true,
      },
      emphasis: {
        focus: 'series',
      },
      data: [422, 355, 755, 655, 487, 565, 757],
    },
    {
      name: '武功山',
      type: 'bar',
      stack: 'total',
      label: {
        show: true,
      },
      emphasis: {
        focus: 'series',
      },
      data: [457, 875, 424, 126, 245, 654, 621],
    },
    {
      name: '明月山',
      type: 'bar',
      stack: 'total',
      label: {
        show: true,
      },
      emphasis: {
        focus: 'series',
      },
      data: [450, 272, 501, 454, 390, 350, 610],
    },
    {
      name: '庐山',
      type: 'bar',
      stack: 'total',
      label: {
        show: true,
      },
      emphasis: {
        focus: 'series',
      },
      data: [520, 232, 301, 244, 450, 330, 620],
    },
  ],
})
/* 初始化echarts数据 */
onMounted(() => {
  /* 获取echarts对象实例 */
  const myEcharts = echarts.init(charts.value)
  /* 渲染初始化数据 */
  myEcharts.setOption(yearTouistCharts)
})
</script>

<style lang="scss" scoped>
.tearTouist {
  width: 100%;
  height: 100%;
  padding-top: 10px;
  .container {
    width: 100%;
    height: 100%;
    background: url('../../images/dataScreen-main-rc.png') no-repeat;
    background-size: 100% 100%;
    /* 标题 */
    .tit {
      width: 100%;
      height: 40px;
      color: #ffff;
      font-size: 22px;
      background: url('../../images/dataScreen-title.png') no-repeat left bottom;
    }
    /*  柱状图 */
    .echarts {
      width: 100%;
      height: 100%;
    }
  }
}
</style>
